package singleton.demo04;

/**
 * 懒汉式(使用同步方法) 保证线程安全, 效率低下
 */
public class Singleton04 {

    private static Singleton04 instance;

    private Singleton04(){};

    public static synchronized Singleton04 getInstance(){
        if (instance == null){
            instance = new Singleton04();
        }
        return instance;
    }
}
